<!DOCTYPE html>
<html lang="en" class="no-js" xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout" layout:decorator="layout">
<head>
<title>促销活动管理</title>
</head>
<body>
<div layout:fragment="content">
	<div class="row">
		<div class="col-md-12">
			<div class="btn-group pull-right">
				<a href="index.html" th:href="@{/promotion/salespromotion/index/}" id="sample_editable_1_new" class="btn green">返回<i class="fa fa-arrow-circle-o-left"></i></a>
			</div>
		</div>
	</div>
	<div class="row">
		<div class="col-md-12">
			<div class="form">
				<form role="form" th:action="@{/promotion/salespromotion/save}" th:object="${sp}" id="spForm" method="post" class="form-horizontal">
					<h4 class="form-section">促销活动信息</h4>
					<input type="hidden" th:field="*{id}" />
					<div class="form-body">
						<div class="form-group" th:class="${#fields.hasErrors('SalesPromotionName')}? 'form-group has-error' : 'form-group'">
							<label class="control-label col-md-3">活动名称<span class="required" aria-required="true">* </span></label>							
							<div class="col-md-4">
								<input type="text" class="form-control" placeholder="活动名称" th:field="*{SalesPromotionName}"/>
								<span class="help-block" th:if="${#fields.hasErrors('SalesPromotionName')}" th:errors="*{SalesPromotionName}">活动名称不能为空</span>
							</div>
						</div>
						<div class="form-group" th:class="${#fields.hasErrors('BeginTime')}? 'form-group has-error' : 'form-group'">
                            <label class="control-label col-md-3">开始时间<span class="required" aria-required="true">* </span></label>
                            <div class="col-md-4">
                                <input id="text_BeginTime" th:field="*{BeginTime}" class="form-control" type="text"></input>
                                <span class="help-block" th:if="${#fields.hasErrors('BeginTime')}" th:errors="*{BeginTime}">请输入开始时间</span>
                            </div>
						</div>
						
						<div class="form-group" th:class="${#fields.hasErrors('EndTime')}? 'form-group has-error' : 'form-group'">
						    <label class="control-label col-md-3">结束时间<span class="required" aria-required="true">* </span></label>
							<div class="col-md-4">
								<input id="text_EndTime" th:field="*{EndTime}" data-format="yyyy-MM-dd hh:mm:ss" class="form-control" type="text"></input>
								<span class="help-block" th:if="${#fields.hasErrors('EndTime')}" th:errors="*{EndTime}">请输入结束时间</span>
							</div>
						</div>

						<div class="form-group">
							<label class="control-label col-md-3">享受优惠会员等级<span class="required" aria-required="true">* </span></label>
							<div class="col-md-5">
					            <div class="checkbox-list">
										<label class="checkbox-inline"
											th:each="data : ${userRanks}"> 
												<span><input
													th:field="*{userRankIdList}"  th:checked="${data.id}" type="checkbox" name="userRankID"
													th:value="${data.id}" th:text="${data.rankName}" id="userRankID"/>
												</span>
									    </label>
								</div>
							</div>
						</div>
						<div class="form-group">
							<label class="control-label col-md-3">促销简介</label>							
							<div class="col-md-4">
								<textarea id="textarea_content" rows="4" type="text" class="form-control" placeholder="促销简介" th:field="*{SalesPromotionExplain}" />
							</div>
						</div>	
					</div>
					<div class="form-actions fluid">
						<div class="col-md-offset-3 col-md-9">
							<button id="bt_submit" type="submit" class="btn blue">提交</button>
						</div>
					</div>
				</form>		
			</div>
		</div>
	</div>
</div>	
</body>
</html>
 <script th:inline="javascript">
	/*<![CDATA[*/
		$("#text_BeginTime").click(function(){
			WdatePicker({startDate:'%y-%M-01 00:00:00',dateFmt:'yyyy-MM-dd HH:mm:ss',alwaysUseStartDate:true,readOnly:true});
		}).focus(function () {
            WdatePicker({startDate:'%y-%M-01 00:00:00',dateFmt:'yyyy-MM-dd HH:mm:ss',alwaysUseStartDate:true,readOnly:true});
        });
		$("#text_EndTime").click(function(){
			WdatePicker({startDate:'%y-%M-01 00:00:00',dateFmt:'yyyy-MM-dd HH:mm:ss',alwaysUseStartDate:true,readOnly:true});
		}).focus(function () {
            WdatePicker({startDate:'%y-%M-01 00:00:00',dateFmt:'yyyy-MM-dd HH:mm:ss',alwaysUseStartDate:true,readOnly:true});
        });
		
		KindEditor.ready(function(K) {
	        var editor = K.create('#textarea_content', {
	                uploadJson : '/upload/SALESPROMOTION',
	                allowFileManager : false
	     });
	        editor.clickToolbar('multiimage',function(){
		    	   if($.browser.mozilla){
		    		   editor.hideDialog();
		    		   alert('请使用谷歌或者IE浏览器进行多文件的上传，火狐浏览器暂不支持!');
		    		   return false;
		    	   }
		       });
	});
		
		$().ready(function() {
			if($.browser.mozilla){
				Metronic.alert({'message':'<span style="color:red;">请使用谷歌或者IE浏览器进行多文件的上传，火狐浏览器暂不支持!</span>'});
			}
			$("#spForm").validate({
		              rules:{
		            	  SalesPromotionName:{
		                      required:true,
		                      maxlength:10
		                  },
		                  userRankIdList:{
		                	  required:true
		                  }
		              },
		              messages:{
		            	  SalesPromotionName:{
		            		  required:"请输入促销活动名称",
		                      maxlength:"最大不能超过10个字符"
		                  },
			              userRankIdList:{
		                	  required:"请选择享受优惠会员等级"
		                  }
		              }		
			});
		});
	           
	/*]]>*/
</script>